<?php
/**
 * @file
 *   Get a list of cards depending on the given filter, Facebook ID, and/or
 *   trade ID.
 */

require_once('../utils/config.php');
require_once('../utils/query.php');

$cards_result = query_select_cards($_POST['type_filter'], $_POST['fb_id'], $_POST['trade_id']);
?>
<ul>
	<?php
	while($row = mysql_fetch_array($cards_result)) {
		$card_id  = $row[0];
		$name     = $row[1];
		$card_img = $row[2];
		
		// Replaces the number on Aspect, Power, and Bane cards in order to
		// display the name of the front of the card.
		$name = str_replace(
			array(' 11', ' 7', ' 3', ' 2', ' 4'),
			array(' 9',  ' 5', ' 1', ' 1', ' 2'),
			$name);
		
		// Truncate the name of the card to prevent overflow.
		if(strlen($name) > 14)
			$showname = substr ($name,0,14) . "...";
		else
			$showname = $name;
		
		// Card format, used in various containers in the UI.
		?>
		<li class="card" id="<?= $card_id; ?>">
			<div class="card_image"> 
				<img src="<?= SERVER_CARD_IMAGES . $card_img; ?>"/> 
			</div>
			
			<div class="card_description" title="<?= $name; ?>">
				<?= $showname; ?>
				<img src = "css/ui-lightness/images/magnifying_glass.png" height = "20" width = "20"/>
			</div>
		</li>
		<?php
	}
	?>
</ul>
